<template>
  <div class="tab_user" @click="lookUser">
    <div class="city" v-if="city">
      {{user.city&&user.city.length>2?user.city.slice(0,2):user.city}}
    </div>
    <div class="">
      <div class="name">
        <span :title="user.name">{{showName(user.name)||''}}</span>
        <img src="@/assets/images/male.png" alt="" v-if="user.gender == '男' || user.sex == 1" />
        <img src="@/assets/images/female.png" alt="" v-else-if="user.gender == '女' || user.sex == 2">
        <img src="@/assets/images/unknown.png" alt="" v-else>
      </div>
      <div class="mobile">
        <!-- {{user.mobile||user.customerPhone||user.phone||''}} -->
      </div>
    </div>
  </div>
</template>
<script>
import { broadcast } from "@/utils/util";
export default {
  name: "TabUser",
  props: {
    user: {
      type: Object,
      default: () => {
        return {};
      },
    },
    city: {
      type: Boolean,
      default: true,
    },
    list: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  data() {
    return {
      showDialog: false,
    };
  },
  mounted() {},
  methods: {
    // 查看用户信息
    lookUser() {
      let row = this.user;
      let list = this.list;
      broadcast("look.user.follow", { data: row, list: list });
    },

    // 展示用户姓名
    showName(str) {
      let o = str;
      if (!str) {
        return "";
      }
      if (str.length > 4) {
        o = str.slice(0, 4) + "...";
      }
      return o;
    },
  },
};
</script>
<style lang="scss" scoped>
.tab_user {
  display: flex;
  align-items: center;
  cursor: pointer;
  .city {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: #167fff;
    border-radius: 4px;
    font-size: 14px;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    color: #ffffff;
    text-align: center;
    line-height: 32px;
    margin-right: 7px;
  }
  .name {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #167fff;
    width:100px;
    img {
      width: 14px;
      height: 14px;
      margin-left: 7px;
    }
  }
  .mobile {
    font-size: 12px;
    font-family: DIN-Regular, DIN;
    font-weight: 400;
    color: #999999;
    margin: 0;
    padding: 0;
  }
}
.dialog_btn {
  .btn {
    width: 88px;
    height: 32px;
    border-radius: 4px;
    border: 0;
    font-size: 14px;
    font-family: PingFang SC-Regular, PingFang SC;
    font-weight: 400;
    cursor: pointer;
    margin-left: 16px;
  }
  .btn:hover {
    opacity: 0.8;
  }
  .btn_primary {
    background: #cce2ff;
    color: #167fff;
  }
  .btn_warning {
    background: #ffe3cc;
    color: #ff8f2e;
  }
  .btn_danger {
    background: #ffcccc;
    color: #ff5e59;
  }
}
</style>